// 路由表
import { createBrowserRouter, Navigate } from "react-router-dom";
import { lazy } from "react";
import obj from "./basis/index";
import App from "../App";
import Login from "../components/pzb/login";
import Ziqia from "../components/lcc/Ziqia";
import DashLayout from "@/components/Data_Dashboard/DashLayout";
const Home = lazy(() => import("../components/Home/Home"));
const Grid_area  = lazy(()=>import("../components/GridMap/Grid_area"))
const New  = lazy(()=>import("../components/GridMap/New"))
const Dangjian = lazy(()=>import("../components/lcc/Dangjian"))

// const Dashboard = lazy(()=>import("../components/Data_Dashboard/Dashboard"))
const Activity = lazy(
  () => import("../components/Party affairs/Activity/Activity")
);
const Course = lazy(() => import("../components/Party affairs/Course/Course"));
const Birthday = lazy(
  () => import("../components/Party affairs/Birthday/Birthday")
);
const Report = lazy(() => import("../components/Party affairs/Report/Report"));
const Video = lazy(
  () => import("../components/Rural security/Video surveillance/Video")
);
const NotFound = lazy(() => import("../components/pzb/NotFound"));
const PartyMembersToStudy = lazy(() => import('../components/learningManagement/partyMembersToStudy/partyMembersToStudy'))
const PoliciesAndRegulations = lazy(() => import('../components/learningManagement/PoliciesAndRegulations/PoliciesAndRegulations'))
const AddPoliciesAndRegulations = lazy(() => import('../components/learningManagement/PoliciesAndRegulations/AddPoliciesAndRegulations/AddPoliciesAndRegulations'))
const SpecialEducation = lazy(() => import('../components/learningManagement/SpecialEducation/SpecialEducation'))
const AddSpecialEducation = lazy(() => import('../components/learningManagement/SpecialEducation/AddSpecialEducation/AddSpecialEducation'))
const ItemBank = lazy(() => import('../components/learningManagement/ItemBank/ItemBank'))
const QuestionnaireDatabase = lazy(() => import('../components/learningManagement/QuestionnaireDatabase/QuestionnaireDatabase'))
const OnlineExamination = lazy(() => import('../components/learningManagement/OnlineExamination/OnlineExamination'))
const Peopleliveserve = lazy(() => import("../components/pzb/Peopleliveserve"));
const NotificationAnnouncement = lazy(
  () => import("../components/pzb/NotificationAnnouncement")
);
const Contacts = lazy(() => import("../components/pzb/Contacts"));
const Workrecords = lazy(() => import("../components/pzb/Workrecords"));
const Questionnaireform = lazy(
  () => import("../components/pzb/Questionnaireform")
);

const Rolemanagement = lazy(() => import("../components/pzb/Rolemanagement"));
const Usermanagement = lazy(() => import("../components/pzb/Usermanagement"));
const Organizationmanagement = lazy(
  () => import("../components/pzb/Organizationalmanagement")
);

//智慧党建
const PartyOrganizationManagement = lazy(
  () =>
    import(
      "../components/MXK/OrganizationalManagement/PartyOrganizationManagement"
    )
);
const LeadingBody = lazy(
  () => import("../components/MXK/OrganizationalManagement/LeadingBody")
);
const PartyMemberManagement = lazy(
  () =>
    import("../components/MXK/OrganizationalManagement/PartyMemberManagement")
);
const NotificationReport = lazy(
  () => import("../components/MXK/DynamicNews/NotificationReport")
);
const ImportantNewsOfPartyBuilding = lazy(
  () => import("../components/MXK/DynamicNews/ImportantNewsOfPartyBuilding")
);
const PublicityWithinTheParty = lazy(
  () => import("../components/MXK/DynamicNews/PublicityWithinTheParty")
);
const OpeningOfThePartyAffairs = lazy(
  () => import("../components/MXK/DynamicNews/OpeningOfThePartyAffairs")
);



//系统管理
const Systemadministration = lazy(
  () => import("@/components/pzb/Systemadministration")
);
// import Login from "@/components/pzb/login";
const { LOGIN, NOTF_FOUND } = obj
const Dashboard = lazy(() => import("../components/Data_Dashboard/Dashboard"))
const Map1 = lazy(() => import("../components/Data_Dashboard/MapContainer"))


let IsLogin = (Props: any) => {
  if (sessionStorage.getItem("accessToken")) {
    return Props.children;
  } else {
    return <Navigate to="/login"></Navigate>;
  }
};
let ls = [
  {
    path: "/app",
    element: (
      <IsLogin>
        {" "}
        <App></App>
      </IsLogin>
    ),
    children: [
      {
        path: "/app/home",
        element: <Home />,
      },

      {
        path: "/app/partyorganizationmanagement",
        element: <PartyOrganizationManagement />,
      },
      {
        path: "/app/leadingbody",
        element: <LeadingBody />,
      },
      {
        path: "/app/partymembermanagement",
        element: <PartyMemberManagement />,
      },
      {
        path: "/app/notificationreport",
        element: <NotificationReport />,
      },
      {
        path: "/app/importantnewsofpartybuilding",
        element: <ImportantNewsOfPartyBuilding />,
      },
      {
        path: "/app/publicitywithintheparty",
        element: <PublicityWithinTheParty />,
      },
      {
        path: "/app/openingofthepartyaffairs",
        element: <OpeningOfThePartyAffairs />,
      },

      {
        path: "/app/grid_area",
        element: <Grid_area />,
      },
      // 智慧党建》党务工作》思想汇报 
      {
        path: "/app/report",
        element: <Report />,
      },
      // 智慧党建》党务工作》政治生日     
      {
        path: "/app/birthday",
        element: <Birthday />,
      },
      // 智慧党建》党务工作》活动报名
      {
        path: "/app/activity",
        element: <Activity />,
      },
      // 智慧党建》党务工作》三会一课
      {
        path: "/app/course",
        element: <Course />,
      },

      // 乡村安防》视频监控》视频
      {
        path: "/app/video",
        element: <Video />,
      },
      {
        // 乡村服务 基层办公 通知公告
        path: "/app/NotificationAnnouncement",
        element: <NotificationAnnouncement />,
      },
      // 乡村服务 基层办公 通训录
      {
        path: "/app/Contacts",
        element: <Contacts />,
      },
      // 乡村服务 基层办公 工作记录
      {
        path: "/app/Workrecords",
        element: <Workrecords />,
      },
      // 乡村服务 基层办公 问卷调查
      {
        path: "/app/Questionnaireform",
        element: <Questionnaireform />,
      },
      // 乡村服务 基层办公 民生服务

      {

        path: "/app/NotificationAnnouncement"
        , element: <NotificationAnnouncement />
      },
      // 智慧党建-学习管理-党员学习
      {
        path: "/app/partyMembersToStudy",
        element: <PartyMembersToStudy />,
      },
      // 智慧党建-学习管理-政策法规
      {
        path: "/app/policiesAndRegulations",
        element: <PoliciesAndRegulations />,
      },
      //智慧党建-学习管理-政策法规-新增/修改页
      {
        path: "/app/addpoliciesAndRegulations",
        element: <AddPoliciesAndRegulations />,
      },
      // 智慧党建-学习管理-专题教育
      {
        path: "/app/specialEducation",
        element: <SpecialEducation />,
      },
      // 智慧党建-学习管理-专题教育-新增/修改页 AddSpecialEducation
      {
        path: "/app/addSpecialEducation",
        element: <AddSpecialEducation />,
      },
      // 智慧党建-学习管理-试题库
      {
        path: "/app/itemBank",
        element: <ItemBank />,
      },
      // 智慧党建-学习管理-问卷库
      {
        path: "/app/questionnaireDatabase",
        element: <QuestionnaireDatabase />,
      },
      // 智慧党建-学习管理-在线考试
      {
        path: "/app/onlineExamination",
        element: <OnlineExamination />,
      },
      {
        path: "/app/Contacts"
        , element: <Contacts />
      },
      {
        path: "/app/Workrecords"
        , element: <Workrecords />
      },
      {
        path: "/app/Questionnaireform"
        , element: <Questionnaireform />
      },
      {
        path: "/app/Peopleliveserve",
        element: <Peopleliveserve />,
      },
      { path: "/app/new", element: <New /> },
    ],

  },

  // 数据可视化
  {
    path: "/dashboard",
    element: <Dashboard />,
    // element: <Navigate to="/dashboard/map"></Navigate>,
    children: [
      // 数据可视化地图
      {
        path: "/dashboard/map1",
        element: <Map1 />,
      },
      {
        path: "/dashboard/dangjian",
        element: <Dangjian />,
      },
      {
        path: "/dashboard/ziqia",
        element: <Ziqia />,
      },
    ],
  },
  // 登录
  LOGIN,
  // 404
  NOTF_FOUND,
  //系统管理
  {
    path: "/Systemadministration",
    element: <Systemadministration></Systemadministration>,

    children: [
      {
        path: "/Systemadministration/Rolemanagement",
        element: <Rolemanagement />,
      },
      {
        path: "/Systemadministration/Usermanagement",
        element: <Usermanagement />,
      },
      {
        path: "/Systemadministration/Organizationalmanagement",
        element: <Organizationmanagement />,
      },
      {
        path: '/Systemadministration',
        element: <Navigate to="/Systemadministration/Organizationalmanagement"></Navigate>
      },
    ]
  },
  {
    path: "/notfount",
    element: <NotFound></NotFound>,
    children: []
  },
  {
    path: "/",
    element: <Navigate to="/login"></Navigate>,
  },

  {
    path: "*",
    element: <Navigate to="/notfount"></Navigate>,
  },
];
const router = createBrowserRouter(ls);
export default router;
